#include<bits/stdc++.h>
#define int long long
#define ls(x) ((x)*2)
#define rs(x) ((x)*2+1)
#define Debug(...) fprintf(stderr, __VA_ARGS__)
#define For(i,a,b) for(int i=a,i##end=b;i<=i##end;i++)
#define Rof(i,a,b) for(int i=a,i##end=b;i>=i##end;i--)
#define rep(i,  b) for(int i=1,i##end=b;i<=i##end;i++)
using namespace std;
const int N=1e6+5,base=999983,Mod=998244353;
//char buf[(1<<21)+5],*p1,*p2;
//#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
inline void chmx(int &x,int y){(x<y)&&(x=y);}
inline void chmn(int &x,int y){(x>y)&&(x=y);}
inline void Add(int &x,int y){(x=x+y+Mod)%=Mod;}
inline int read(){
	int f=0,x=0;
	char ch=getchar();
	while(!isdigit(ch)){f|=(ch=='-');ch=getchar();}
	while(isdigit(ch)){x=(x<<3)+(x<<1)+(ch^48);ch=getchar();}
	return f?-x:x;
}
void print(int n){
    if(n<0){
        putchar('-');
        n*=-1;
    }
    if(n>9) print(n/10);
    putchar(n%10+'0');
}
int n,tot,val[N];
vector<int>EE[N],q[N];
vector<pair<int,int> >e[N];
int siz[N],v[N];
int ans[N],f[N][21],st[N][21];
void dfs(int x,int fa,int c){
	siz[x]=(val[x]>=c);v[x]=0;
	for(auto y:q[x]){
		if(y==fa)continue;
		dfs(y,x,c);
		if(val[x]>=c)siz[x]+=siz[y],v[x]+=v[y];
	}
	if(val[x]==c) v[x]=siz[x];
}
int answer=0;
int kans=0; 
void dfs2(int x,int fa,int lst,int llst,int c){
//	if(x==1) return;
	if(val[x]>=c){
		if(val[x]==c){
			int p=lst;
			int res=0;
			for(auto v:q[x]){
				if(v==fa) continue;
				p+=siz[v];
			}res+=p*p; 
			for(auto v:q[x]){
				if(v==fa) continue;
				res-=(siz[v])*siz[v];
			}
			res-=lst*lst;
			res/=2;
			res+=p+1;
			ans[x]+=res*c;
//cout<<x<<" "<<fa<<" "<<lst<<" "<<llst<<" "<<res<<" "<<" "<<c<<endl; 
		}
		else{
			int p=llst,qq=lst-llst;
			int res=0;
			for(auto y:q[x]){
				if(y==fa) continue;
				res+=(v[y]*p);
				p+=v[y];qq+=siz[y]-v[y];
			}res+=p;
			for(auto y:q[x]){
				if(y==fa) continue;
				res+=(qq-(siz[y]-v[y]))*v[y];
			}res+=(qq-(lst-llst))*llst;
			ans[x]+=res*c;
//cout<<"1"<<x<<" "<<fa<<" "<<lst<<" "<<llst<<" "<<res<<" "<<" "<<c<<" "<<val[x]<<endl; 
		}
	}
	int p=lst+siz[x],t=llst+v[x];
	if(val[x]==c){
		answer+=(p-1)*c;
		kans+=p-1;
	}
	else if(val[x]>c){
		answer+=t*c;
		kans+=t;
	}
	for(auto y:q[x]){
		if(y==fa) continue;
		dfs2(y,x,siz[x]?p-siz[y]:0,siz[x]?(val[x]==c?lst+siz[x]-siz[y]:t-v[y]):0,c);
	}
}
int U[N],V[N];
int id[N],dep[N];
void dfs1(int x,int fa){
	for(auto EE:e[x]){
		if(EE.first==fa) continue;
		id[EE.first]=EE.second;
		q[id[x]].push_back(EE.second);
		dep[EE.second]=dep[id[x]]+1;
		f[EE.second][0]=id[x];st[EE.second][0]=val[EE.second];
		q[EE.second].push_back(id[x]);
		dfs1(EE.first,x);
	}
}
inline int calc(int x,int y){
	if(x==y) return val[x];
	if(dep[x]<dep[y]) swap(x,y);
	int res=1e16;
	Rof(i,20,0){
		if(dep[f[x][i]]>=dep[y]) {
			res=min(res,st[x][i]);
			x=f[x][i];
		}
	}
	res=min(res,val[x]);
	res=min(res,val[y]);
	Rof(i,20,0){
		if(f[x][i]!=f[y][i]){
			res=min(res,st[x][i]);
			res=min(res,st[y][i]);
			x=f[x][i],y=f[y][i];
		}
	}
	res=min(res,val[x]);
	res=min(res,val[y]);
//	cout<<x<<" "<<y<<" "<<res<<endl;
	if(x==y) return res;
	res=min(res,val[f[x][0]]);
	return res;
} 
int dis[N];
int faz[N];
int find(int x){
	return faz[x]=(faz[x]==x?x:find(faz[x]));
}
signed main(){
	freopen("tatooine.in","r",stdin);
	freopen("tatooine.out","w",stdout);
	// ios::sync_with_stdio(false);
	// cin.tie(0); cout.tie(0);
	n=read();
	++tot;
	For(i,1,n-1){
		int u=read(),v=read();
		val[++tot]=read();U[tot]=u,V[tot]=v;
		e[u].push_back({v,tot}),e[v].push_back({u,tot});
	}id[1]=1;dep[1]=1;
	dfs1(1,0);
	For(i,1,30){
		dfs(1,0,i);
		int pp=0,qq=0;
		for(auto x:q[1]){
			if(siz[x])pp+=siz[x],qq+=v[x];
		}
		for(auto x:q[1])dfs2(x,1,pp-siz[x],qq-v[x],i);
	} val[1]=1e16;
	answer/=2;
	For(i,2,n) answer+=val[i],kans++;
	if(n<=2000){
		For(j,1,20) For(i,1,n) f[i][j]=f[f[i][j-1]][j-1],st[i][j]=min(st[f[i][j-1]][j-1],st[i][j-1]);
//		cout<<calc(2,4)<<endl;
//		return 0;
		For(t,2,n){
			For(i,1,n) faz[i]=i;
			For(i,1,n){
				for(auto v:q[i]){
					if(v==t||i==t) continue;
					if(find(i)==find(t)) continue;
					faz[find(v)]=find(i);
				}
			}answer=0;
			For(i,2,n){
				For(j,i,n){
					if(i==t||j==t) continue; 
					if(find(i)==find(j)){
						answer+=calc(i,j);
//						cout<<i<<" "<<j<<" "<<calc(i,j)<<endl;
					}
				}
			}
			printf("%lld\n",answer);
		}
		return 0;
	}
//	cout<<(n-1)*(n-1)<<" "<<kans<<endl;
//cout<<answer<<endl;
	For(i,2,n){
		printf("%lld\n",answer-ans[i]);
	} 
#ifdef LOCAL
    Debug("\nMy Time: %.3lfms\n", (double)clock() / CLOCKS_PER_SEC);
#endif
	return 0;
}

